from socket import *
from time import ctime

HOST = ""
PORT = 21568
BUFSIZE = 1024

ADDR = (HOST, PORT)

tcpSocket = socket(AF_INET,SOCK_STREAM)
tcpSocket.bind(ADDR)
tcpSocket.listen(5)

while True:
    print 'waiting for connection...'
    cs, addr = tcpSocket.accept()
    print 'connected from:',addr

    while True:
        data = cs.recv(BUFSIZE)
        if not data:
            break
        cs.send('[%s] %s' % (ctime(),data))

    cs.close()

tcpSocket.close()
